/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit_vendor_management;

/**
 *
 * @author QuangKhoi
 */
public class VendorType {
    public String MaLoaiDaiLy = "";
    public String TenLoaiDaiLy = "";
    
    public VendorType(String MaLoaiDaiLy) {
        QueryResult result = Database.instance.Query("SELECT MaLoaiDaiLy, "
                + "TenLoaiDaiLy FROM LOAIDAILY "
                + "WHERE MaLoaiDaiLy='" + MaLoaiDaiLy + "'");
        if (result.Count == 1) {
            this.MaLoaiDaiLy = MaLoaiDaiLy;
            this.TenLoaiDaiLy = result.Table.getString(0, 1);
        }
    }
    
    public VendorType() {
        QueryResult result = Database.instance.Query("SELECT MaLoaiDaiLy, "
                + "TenLoaiDaiLy FROM LOAIDAILY");
        if (result.Count > 0) {
            this.MaLoaiDaiLy = result.Table.getString(0, 0);
            this.TenLoaiDaiLy = result.Table.getString(0, 1);
        }
    }
    
    public static javax.swing.DefaultComboBoxModel getModel() {
        QueryResult result = Database.instance
                .Query("SELECT MaLoaiDaiLy, TenLoaiDaiLy FROM LoaiDaiLy");
        String[] model = new String[result.Count];
        for (int i = 0; i < result.Count; i++) {
            model[i] = result.Table.getString(i, 1);
        }
        return new javax.swing.DefaultComboBoxModel(model);
    }
}
